<%-- Prepares data for page to render. Part of data will be rendered by inputmsgs tag,
	in place where that other tag is put. Keep in mind that next invokation wipes data slots
	used for previous fileds. TODO: maybe it's necessary to allocate individual slots for all fields
	Please preserve this file in its current format so that no whitespace is generated into HTML.

	Example usage:
		<tf:input errorClass="err" name="<%= AccountBuilderConstants.OLD_PASSWORD %>"/>

	--%><%@ tag import="org.apache.struts.action.ActionMessages,java.util.Iterator "%>
<%@ tag import="org.ttjhome.html.struts.candidate.Constants"%>
<%@ tag display-name="input" body-content="tagdependent"%>
<%@ attribute name="errorClass" required="false" %>
<%@ attribute name="name"%>
<%
	//jspContext.getOut().print( name );
	jspContext.setAttribute("inputName", name, PageContext.REQUEST_SCOPE);
	ActionMessages messages = (ActionMessages) jspContext.getAttribute(Constants.ACTION_MESSAGES, PageContext.REQUEST_SCOPE);
	//jspContext.getOut().print(messages);
	if (messages != null) {
		Iterator iterator = messages.get(name);
		//jspContext.getOut().print(iterator.hasNext());
		if (iterator.hasNext()) {
			jspContext.setAttribute("input.messages", iterator, PageContext.REQUEST_SCOPE);
			jspContext.setAttribute("errorStyle", "style=\"color: red;\"", PageContext.REQUEST_SCOPE);
			if ( errorClass != null )
			{
				jspContext.setAttribute("err", errorClass, PageContext.REQUEST_SCOPE);
			}
		} else {
			// so that it does not get carried over from previous field
			jspContext.removeAttribute("input.messages", PageContext.REQUEST_SCOPE);
			jspContext.removeAttribute("errorStyle", PageContext.REQUEST_SCOPE);
			jspContext.removeAttribute("err", PageContext.REQUEST_SCOPE);
		}
	}
%>
